import {
    CRC16,
    stringToAsciiBytes,
    MsgType,
    DeviceMessageSend,
    DeviceMessageReceive,
    CommonConfirmReplyMsgBody,
    RecipeSendMsgBody,
    RecipeStepInfo,
    RecipeStartCookingMsgBody,
    ElectronicScaleFoodPreparationMsgBody,
    FoodWeightInfo,
    RangeHoodFanControlMsgBody,
    SettingSeasoningRatioCalibrationMsgBody,
    SeasoningRatioCalibrationInfo,
    ManualAddSeasoningMsgBody,
    SeasoningAddInfo,
    SettingSeasoningBaseUnitMsgBody,
} from '@/utils/deviceProtocolUtil.js'

import {
    DeviceModel, 
    DeviceStatus,
} from '@/interface/device.js'

/**
 * 设备协议服务基础类
 */
export class DeviceProtocolBase {
    // 设备发现服务
    deviceDiscoverStore
    // 设备通信服务
    deviceProtocolStore
    // 设备消息事件监听器
    deviceMessageListener
    // 设备本地存储数据库
    deviceStore

    constructor() {
        this.deviceDiscoverStore = useOutsideDeviceDiscoverStore()
        this.deviceProtocolStore = useOutsideDeviceProtocolStore()
        this.deviceMessageListener = []
        
        // 等待store初始化后之后再拿
        nextTick(_ => {
            this.deviceStore = useOutsideDeviceStore()
        })
    }
    
    /**
     * 获取当前在线设备列表
     */
    getOnlineDeviceList() {
        let deviceList = this.deviceProtocolStore.getDeviceSessionList()
        console.log(deviceList)
        return deviceList
    }
    
    /**
     * 获取当前发送广播的设备列表
     * 搜索绑定设备的时候需要使用
     */
    getBroadcastDeviceList() {
        let deviceList = this.deviceDiscoverStore.getDeviceSessionList()
        console.log(deviceList)
        return deviceList
    }
}